import java.util.ArrayList;
import java.util.List;
import java.util.*;

public class Main {
    static int findMissingNumber(int start, int end, List<Integer> list) {
        return 0;
    }
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("apple"); // size=1
        list.add(null); //允许添加空
        list.add("pear"); // size=3
        String second = list.get(1); // null
        System.out.println(second);
        List<Integer> list2 = List.of(1, 2, 5);//List.of不接受null值
        //list转化为array 三个方式
        //1·强制类型转换
        Object[] array = list.toArray();
        for (Object s : array) {
            System.out.println(s);
        }
        //2传入array
        Integer[] array2 = list2.toArray(new Integer[3]);
        for (Integer n : array2) {
            System.out.println(n);
        }
        List<Integer> list3 = List.of(12, 34, 56);
        Number[] array3 = list3.toArray(new Number[3]);
        for (Number n : array3) {
            System.out.println(n);
        }
        final int start = 10;
        final int end = 20;
        List<Integer> list4 = new ArrayList<>();
        for (int i = start; i <= end; i++) {
            list4.add(i);
        }
        int removed = list4.remove((int) (Math.random() * list.size()));
        int found = findMissingNumber(start, end, list4);
        System.out.println(list.toString());
        System.out.println("missing number: " + found);
        System.out.println(removed == found ? "测试成功" : "测试失败");

    }
}
